package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.AdChannelDto;
import com.heima.model.wemedia.dtos.ChannelPageDto;
import com.heima.wemedia.service.WmChannelService;
import com.sun.org.apache.regexp.internal.RE;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 自媒体频道表(WmChannel)表控制层
 *
 * @author makejava
 * @since 2023-06-14 09:36:40
 */
@RestController
@RequestMapping("/api/v1/channel")
@Api(tags = "频道接口")
public class WmChannelController {
    /**
     * 服务对象
     */
    @Resource
    private WmChannelService wmChannelService;

    @ApiOperation("频道列表查询接口")
    @GetMapping("/channels")
    public ResponseResult getChannelList(){



        return wmChannelService.getChannelList();
    }


    /**
     * 模糊查询列表
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody ChannelPageDto dto){

        return wmChannelService.pageList(dto);
    }

    /***
     * 删除频道列表
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){

        return wmChannelService.delete(id);
    }

    @PostMapping("/save")
    public ResponseResult save(@RequestBody AdChannelDto dto){

        return wmChannelService.saveChannel(dto);

    }


    /**
     * 修改频道
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody AdChannelDto dto){
        return wmChannelService.updateChannel(dto);
    }



}

